예제 #1
0
    public void OnActivityAssigned(ActivityInformation activityInformation)
    {
        switch (activityInformation.activityType)
        {
        case ActivityType.Quest:
        {
            GameObject ActivityTimerGO = new GameObject(activityInformation.activityID.ToString());
            ActivityTimerGO.transform.SetParent(NotificationManager.Instance.gameObject.transform.Find("ActivitiesList"));

            ClockTimer questTimer = ActivityTimerGO.AddComponent <ClockTimer>();
            questTimer.activityInformation = activityInformation;
            break;
        }

        case ActivityType.Craft:
        {
            GameObject ActivityTimerGO = new GameObject(activityInformation.activityID.ToString());
            ActivityTimerGO.transform.SetParent(NotificationManager.Instance.gameObject.transform.Find("ActivitiesList"));

            PointTimer craftTimer = ActivityTimerGO.AddComponent <PointTimer>();
            craftTimer.activityInformation = (activityInformation);
            break;
        }

        case ActivityType.Build:
        {
            Builder builder = BuildingManager.Instance.AllBuildings.SingleOrDefault(b => b.ID == activityInformation.informationID);

            builder.representGameObject.GetComponent <BuildTimer>().activityInformation = activityInformation;
            Debug.Log($"{builder.representGameObject.GetComponent<BuildTimer>().activityInformation.activityID}");
            break;
        }

        case ActivityType.Pregnancy:
        {
            GameObject ActivityTimerGO = new GameObject(activityInformation.activityID.ToString());
            ActivityTimerGO.transform.SetParent(NotificationManager.Instance.gameObject.transform.Find("ActivitiesList"));

            ClockTimer questTimer = ActivityTimerGO.AddComponent <ClockTimer>();
            questTimer.activityInformation = activityInformation;
            break;
        }

        case ActivityType.CharacterGrowing:
        {
            GameObject ActivityTimerGO = new GameObject(activityInformation.activityID.ToString());
            ActivityTimerGO.transform.SetParent(NotificationManager.Instance.gameObject.transform.Find("ActivitiesList"));

            ClockTimer questTimer = ActivityTimerGO.AddComponent <ClockTimer>();
            questTimer.activityInformation = activityInformation;
            break;
        }

        default:
        {
            Debug.LogWarning($"{activityInformation.activityType} is currently unhandled.");
            break;
        }
        }
    }
예제 #2
0
        private void HandleFutureAction(IRequestQueue queue, PointAction action, PointAction futureAction, uint duration)
        {
            //send the future message

            //cancel any existing timers for this point
            if (FutureActionManager.Current.TryRemove(action.PointID, out PointTimer pointTimer))
            {
                pointTimer.Cancel(false);
            }

            //create a new PointTimer for this point
            pointTimer = new PointTimer(queue, futureAction, duration);

            //keep track of this timer in case it is cancelled
            FutureActionManager.Current.TryAdd(pointTimer);
        }
예제 #3
0
	public void PlayerDied(NetworkPlayer player){

		//We've now lost the final player
		if(lastPlayerTimer != null){
			if(player == lastPlayerTimer.player)
				lastPlayerTimer = null;
		}

		PlayerStats deadPlayerStats = psInfo.GetPlayerStats(player);

		//There is guaranteed to be an event that happened before the player died.
		//But there is no guarantee of an attacker killing the player.
		PlayerEvent lastEvent = deadPlayerStats.LastEvent();
		float validTime = lastEvent.TimeOfContact;

		CircularBuffer<PlayerEvent> events = deadPlayerStats.playerEvents;
		//traverse from newest to oldest
		foreach(PlayerEvent playerEvent in events.Reverse<PlayerEvent>()){
			float eventWindow = EVENT_WINDOW_DEFAULT;
			if(playerEvent.PowerType == PowerType.HOOK)
			{
				eventWindow = EVENT_WINDOW_HOOK;
			}
			if(playerEvent.TimeOfContact >= validTime - eventWindow){
				//Event happened close enough to combo with other event or kill player
				validTime = playerEvent.TimeOfContact;
				NetworkPlayer? attacker = playerEvent.Attacker;
				//Check if the event involved an attacker, so we give points
				if(attacker!= null && attacker.Value != player){
					PlayerStats attackerStats = psInfo.GetPlayerStats(attacker.Value);

					if(attackerStats.timeOfDeath <= playerEvent.TimeOfContact){
						//Attacking player died before the event happened, so give half point.
						GivePoints(2f, attacker.Value);
					}
					else {
						//Give full point
						GivePoints(10f, attacker.Value);
					}
				}
			}
		}
	}
예제 #4
0
    void CheckActivities()
    {
        foreach (var activity in allProcessingActivies)
        {
            switch (activity.Value.activityType)
            {
            case ActivityType.Quest:
            {
                GameObject ActivityTimerGO = new GameObject(activity.Value.activityID.ToString());
                ActivityTimerGO.transform.SetParent(transform.Find("ActivitiesList"));
                ClockTimer questTimer = ActivityTimerGO.AddComponent <ClockTimer>();
                questTimer.activityInformation = activity.Value;
                break;
            }

            case ActivityType.Craft:
            {
                GameObject ActivityTimerGO = new GameObject(activity.Value.activityID.ToString());
                ActivityTimerGO.transform.SetParent(transform.Find("ActivitiesList"));
                PointTimer craftTimer = ActivityTimerGO.AddComponent <PointTimer>();
                craftTimer.activityInformation = (activity.Value);
                break;
            }

            case ActivityType.Build:
            {
                Builder builder = BuildingManager.Instance.AllBuildings.SingleOrDefault(b => b.ID == activity.Value.informationID);

                BuildTimer buildTimer = builder.representGameObject.GetComponent <BuildTimer>();
                if (buildTimer)
                {
                    buildTimer.activityInformation = activity.Value;
                    buildTimer.UpdateNewFinishTime();
                }
                break;
            }

            case ActivityType.Pregnancy:
            {
                GameObject ActivityTimerGO = new GameObject(activity.Value.activityID.ToString());
                ActivityTimerGO.transform.SetParent(NotificationManager.Instance.gameObject.transform.Find("ActivitiesList"));
                ClockTimer questTimer = ActivityTimerGO.AddComponent <ClockTimer>();
                questTimer.activityInformation = activity.Value;

                break;
            }

            case ActivityType.CharacterGrowing:
            {
                GameObject ActivityTimerGO = new GameObject(activity.Value.activityID.ToString());
                ActivityTimerGO.transform.SetParent(NotificationManager.Instance.gameObject.transform.Find("ActivitiesList"));
                ClockTimer questTimer = ActivityTimerGO.AddComponent <ClockTimer>();
                questTimer.activityInformation = activity.Value;

                break;
            }

            default:
            {
                Debug.LogWarning($"{activity.Value.activityType} is currently unhandled.");
                break;
            }
            }
        }
    }
예제 #5
0
    public void OnActivityFinished(ActivityInformation activityInformation)
    {
        switch (activityInformation.activityType)
        {
        case ActivityType.Quest:
        {
            /// Update in Notification Panel
            break;
        }

        case ActivityType.Craft:
        {
            Resource resource = LoadManager.Instance.allResourceData.SingleOrDefault(r => r.Value.ID == activityInformation.informationID).Value;

            ItemManager.Instance.AddResource(resource.Name, 1);

            PointTimer craftTimer = NotificationManager.Instance.gameObject.transform.Find("ActivitiesList/"
                                                                                           + activityInformation.activityID).GetComponent <PointTimer>();
            Destroy(craftTimer.gameObject);
            RemoveActivity(activityInformation);

            break;
        }

        case ActivityType.Build:
        {
            RemoveActivity(activityInformation);
            break;
        }

        case ActivityType.Pregnancy:
        {
            Character femaleCharacter = CharacterManager.Instance.AllCharacters.SingleOrDefault(c => c.ID == activityInformation.informationID);
            Character maleCharacter   = CharacterManager.Instance.AllCharacters.SingleOrDefault(c => c.ID == activityInformation.informationID2);
            femaleCharacter.workStatus = Character.WorkStatus.Working;

            CharacterManager.Instance.CreateChildCharacter(maleCharacter, femaleCharacter);

            ClockTimer timer = NotificationManager.Instance.gameObject.transform.Find("ActivitiesList/" + activityInformation.activityID).GetComponent <ClockTimer>();
            Destroy(timer.gameObject);
            RemoveActivity(activityInformation);
            break;
        }

        case ActivityType.CharacterGrowing:
        {
            ClockTimer timer = NotificationManager.Instance.gameObject.transform.Find("ActivitiesList/" + activityInformation.activityID).GetComponent <ClockTimer>();
            Destroy(timer.gameObject);

            RemoveActivity(activityInformation);

            Character character = CharacterManager.Instance.AllCharacters.SingleOrDefault(c => c.ID == activityInformation.informationID);
            character.workStatus = Character.WorkStatus.Idle;

            break;
        }

        default:
        {
            Debug.LogWarning($"{activityInformation.activityType} is currently unhandled.");
            break;
        }
        }
    }
예제 #6
0
	public void LastManStanding(NetworkPlayer lastMan){ 
		lastPlayerTimer = new PointTimer(lastMan, 3f);
	}