mirror of
https://github.com/ConjureETS/DeathBook.git
synced 2026-03-24 04:20:58 +00:00
Online/offline functionality tested and running Signed-off-by: RosimInc <rosim_inc@hotmail.com>
68 lines
1.5 KiB
C#
68 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using DeathBook.Util;
|
|
|
|
namespace DeathBook.Model
|
|
{
|
|
public class Friendship : Updatable
|
|
{
|
|
private Person self;
|
|
public Person Self { get { return self; } }
|
|
private Person friend;
|
|
public Person Friend { get { return friend; } }
|
|
|
|
private Friendship other;
|
|
public Friendship Other { get { return other; } set { other = value; } }
|
|
|
|
private FriendshipLink link;
|
|
public FriendshipLink Link { get { return link; } }
|
|
|
|
private bool noticedDeath = false;
|
|
|
|
public Friendship(Person self, Person friend, FriendshipLink link)
|
|
{
|
|
this.self = self;
|
|
this.friend = friend;
|
|
this.link = link;
|
|
}
|
|
|
|
public void NotifyFriendWasKilled()
|
|
{
|
|
Link.KillCount++;
|
|
Self.NotifyFriendWasKilled(this);
|
|
}
|
|
|
|
public void Update(float deltaTime)
|
|
{
|
|
if (noticedDeath)
|
|
return;
|
|
|
|
//This function is only called when friend is dead
|
|
//awareness = Mathf.Min(awareness + deltaTime * CalculateWeight(), 1);
|
|
link.Awareness = Mathf.Min(link.Awareness + deltaTime * 0.1f, 1f);
|
|
if (link.Awareness >= 1f)
|
|
{
|
|
self.NoticeDeath(this);
|
|
noticedDeath = true;
|
|
}
|
|
}
|
|
|
|
//returns a number between 0 and 1
|
|
private float CalculateWeight()
|
|
{
|
|
float weight = 0;
|
|
|
|
weight += link.Importance;
|
|
//weight += friend.TimeBetweenPosts;
|
|
|
|
return weight * 0.1f;
|
|
}
|
|
|
|
/*internal enum Knowledge
|
|
{
|
|
Alive, Doubt, Dead
|
|
}*/
|
|
}
|
|
}
|