Example #1
0
    // Check if Position already has navMeshAgent
    public bool CheckIfPointHasNavMeshAgent(Vector3 point, UnitBaseBehaviourComponent agent)
    {
        if (agent.GetComponent <NavMeshAgent>() == null)
        {
            return(false);
        }

        bool  tmp  = false;
        float sRad = 1.15f;

        RaycastHit[] hit = Physics.SphereCastAll(point, sRad, Vector3.forward, 0);
        PlaceGizmo(point);

        if (hit.Length > 0)
        {
            for (int i = 0; i < hit.Length; i++)
            {
                if (hit[i].transform.GetComponent <NavMeshAgent>() != null && hit[i].transform.GetComponent <UnitBaseBehaviourComponent>() != agent)
                {
                    tmp = true;
                }
            }
        }
        return(tmp);
    }
Example #2
0
 public void ClearComboList()
 {
     unitDoingCombo = null;
     comboList.ForEach(x => x.comboIdx = 0);
     comboList.Clear();
     curTimer = 0;
 }
Example #3
0
        public void SetInterval(UnitBaseBehaviourComponent unit, float baseInterval = 10.0f)
        {
            float reduction = unit.myStats.GetStats(Stats.Strength).GetLevel / 10;

            dmgInterval_C = baseInterval - reduction;
            unitSaved     = unit;
        }
Example #4
0
        public void ClickObject()
        {
            if (CursorManager.GetInstance.IsUserInterfaceClicked())
            {
                return;
            }
            RaycastHit hit;
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(ray, out hit, Mathf.Infinity))
            {
                if (hit.transform.gameObject.GetComponent <UnitBaseBehaviourComponent>())
                {
                    UnitBaseBehaviourComponent tmp = hit.transform.gameObject.GetComponent <UnitBaseBehaviourComponent>();
                    if (unitSelected.Contains(tmp))
                    {
                        return;
                    }
                    else
                    {
                        SelectObject(tmp.unitAffiliation, tmp);
                    }
                }
                else
                {
                    DeinitializeSelectedUnits();
                    unitSelected.Clear();
                }
            }
        }
Example #5
0
        public override void ReceiveDamage(float netDamage, UnitBaseBehaviourComponent unitSender)
        {
            if (currentState != LivingState.Dead)
            {
                myStats.health_C -= netDamage;
                mAnimation.Play();
                mParticleSystem.Play();

                if (myStats.health_C <= 0)
                {
                    myStats.health_C = 0;
                    if (canInteract)
                    {
                        EndAllInteraction();
                        currentState = LivingState.Dead;
                        canInteract  = false;
                        StartCoroutine(StartDeathCounter(5));
                    }
                }
            }
            if (unitSender != null)
            {
                IncrementInteractingUnitsStats(unitSender, netDamage);
            }
        }
Example #6
0
        public void UseItem(UnitBaseBehaviourComponent thisPlayer)
        {
            switch (itemType)
            {
            case ItemType.Belt:
            case ItemType.Boots:
            case ItemType.Cape:
            case ItemType.Glasses:
            case ItemType.Gloves:
            case ItemType.Helmet:
            case ItemType.Necklace:
            case ItemType.Pants:
            case ItemType.Ring:
            case ItemType.Weapon:
            case ItemType.Armor:

                break;

            case ItemType.Potion:
                if (isConsumable)
                {
                    UsePotion(thisPlayer);
                }

                break;
            }
        }
Example #7
0
 // Used To Other Units Right After Arriving at one point.
 public void AdjustNearbyNavMeshDestination(UnitBaseBehaviourComponent dontCheck)
 {
     foreach (Character item in GetEntities <Character>())
     {
         // check if they're moving already
         if (item.unitBehaviour != dontCheck)
         {
             if (item.unitBehaviour.startMoving)
             {
                 // Check if Destination is near point received from player who just reached his.
                 if (item.unitBehaviour.nextPos == null)
                 {
                     break;
                 }
                 float dist = Vector3.Distance(dontCheck.nextPos, item.unitBehaviour.nextPos);
                 //Debug.Log("Distance Between : " + item.unitBehaviour.transform.name + " And : " + dontCheck.transform.name + " is : " + dist);
                 if (dist < 1.15f)
                 {
                     //Debug.Log("Adjusting Pos : " + item.unitBehaviour.transform.name + " Old Pos : " + item.unitBehaviour.nextPos);
                     if (item.unitBehaviour.interactWith != null)
                     {
                         item.unitBehaviour.nextPos = NavMeshPositionGenerator.GetInstance.GenerateCandidatePosition(item.unitBehaviour.interactWith.transform.position, 2, item.unitBehaviour, false);
                     }
                     else
                     {
                         item.unitBehaviour.nextPos = NavMeshPositionGenerator.GetInstance.GenerateCandidatePosition(item.unitBehaviour.nextPos, 2, item.unitBehaviour, false);
                     }
                     // Debug.Log("New Pos : " + item.unitBehaviour.nextPos);
                 }
             }
         }
     }
 }
Example #8
0
        public void AddToUnitControlled(Parameters p)
        {
            UnitBaseBehaviourComponent check = p.GetWithKeyParameterValue <UnitBaseBehaviourComponent>("UnitControlled", null);

            if (check != null)
            {
                if (check.unitAffiliation == UnitAffiliation.Player || check.unitAffiliation == UnitAffiliation.Controlled)
                {
                    if (!controlledUnits.Contains(check))
                    {
                        controlledUnits.Add(check);
                    }

                    if (check.unitAffiliation == UnitAffiliation.Player)
                    {
                        List <UnitBaseBehaviourComponent> newSetSelected = new List <UnitBaseBehaviourComponent>();
                        newSetSelected.Add(check);
                        foreach (UnitBaseBehaviourComponent item in controlledUnits)
                        {
                            if (item != check)
                            {
                                newSetSelected.Add(item);
                            }
                        }
                        controlledUnits.Clear();
                        controlledUnits = newSetSelected;
                    }
                }
            }
        }
Example #9
0
    public void AddToUnitControlled(Parameters p)
    {
        bool isInitialSetup = false;
        UnitBaseBehaviourComponent check = p.GetWithKeyParameterValue <UnitBaseBehaviourComponent>("UnitControlled", null);

        //Debug.Log("AddToUnitControlled Initialize : " + check.name);
        if (check == null)
        {
            return;
        }

        if (check.unitAffiliation == UnitAffiliation.Player)
        {
            AdjustUnitListDueToPlayer(check);
        }
        else
        {
            if (fourUnits.Count <= 0)
            {
                //Debug.Log("Meow Mic Test");
                isInitialSetup = true;
                PlayerUnitController.GetInstance.unitSelected.Add(check);
                PlayerUnitController.GetInstance.CheckAndSetManualUnit(0);
            }

            if (!fourUnits.Contains(check))
            {
                fourUnits.Add(check);
            }
        }
        SetInventoryOwner(check);
        SetStatsOwner(check);
        characterHandler.RefreshCharacterHandlers(fourUnits);
    }
Example #10
0
 public virtual void IncrementInteractingUnitsStats(UnitBaseBehaviourComponent unit, float valueToAdd = 5.0f)
 {
     foreach (Stats item in statsToCompute)
     {
         unit.myStats.GetStats(item).IncreaseExperience(valueToAdd);
         Debug.Log("Current Unit Stats is : " + item + " Exp : " + unit.myStats.GetStats(item).GetCurrentExperience + "/" + unit.myStats.GetStats(item).GetNextLevelExperience);
     }
 }
Example #11
0
 // 2
 public bool IsUnitGathering(UnitBaseBehaviourComponent unit)
 {
     if (!interactingUnit.Contains(unit))
     {
         return(false);
     }
     return(unit.currentCommand == Commands.GATHER_RESOURCES);
 }
Example #12
0
    public void SetUnitIdentity(UnitBaseBehaviourComponent unit)
    {
        CharacterStatsSystem stats = unit.myStats;

        unitName.text  = "Name: " + stats.name;
        unitTitle.text = "Title: " + "Commoner";
        unitRace.text  = "Race: " + "Cube";
    }
Example #13
0
    public Vector3 ObtainPosition(Vector3 clickPosition, UnitBaseBehaviourComponent unit, float positionSpacing = 0.5f)
    {
        Vector3 newPosition = unit.transform.position;

        newPosition = GenerateCandidatePosition(clickPosition, 2, unit);

        return(newPosition);
    }
Example #14
0
    public bool CheckVectorIfPathable(UnitBaseBehaviourComponent unit, Vector3 candidatePos)
    {
        NavMeshPath nav = new NavMeshPath();

        unit.gameObject.GetComponent <NavMeshAgent>().CalculatePath(candidatePos, nav);

        return(nav.status == NavMeshPathStatus.PathComplete);
    }
Example #15
0
 public void ActivateSkill(UnitBaseBehaviourComponent activateTo)
 {
     activate = true;
     if (!affectedUnits.Contains(activateTo))
     {
         affectedUnits.Add(activateTo);
     }
     activateTo.ReceiveBuff(skillEffect);
 }
Example #16
0
 public void SetUnitDoingCombo(UnitBaseBehaviourComponent unit)
 {
     EventBroadcaster.Instance.PostEvent(EventNames.RESET_VISUAL_SKILLS);
     ClearComboList();
     unitDoingCombo = unit;
     comboList.Clear();
     // Adds Buff
     comboList.AddRange(unit.mySkills.buff);
     comboList.AddRange(unit.mySkills.fireMagic);
 }
Example #17
0
 public void DeinitializeSelectedUnits()
 {
     foreach (UnitBaseBehaviourComponent item in unitSelected)
     {
         item.RemoveFromSelected();
     }
     unitSelected.Clear();
     manualControlledUnit = null;
     comboComponent.ClearComboList();
 }
Example #18
0
        public void ShowInteractWithPopup(UnitBaseBehaviourComponent unit, UnitBaseBehaviourComponent interactingWith)
        {
            interactors.Clear();

            // TODO : IMPLEMENT UNKNOWN IDENTIFICATION UPON FIRST INTERACTION.
            interactWithPopup.header.text        = interactingWith.myStats.name;
            interactWithPopup.transform.position = Input.mousePosition;
            interactWithPopup.gameObject.SetActive(true);
            interactors.Add(unit);
            interactWithPopup.SetPotentialOptions(interactingWith.potentialActionTypes);
            interactee = interactingWith;
        }
Example #19
0
 public void InitializeGathererStats(UnitBaseBehaviourComponent unit, UnitGatheringResourceStats tmp)
 {
     if (!tmp.dataInitialized)
     {
         tmp.SetInterval(unit, dmgInterval_B);
         tmp.GetAtkType = new Attack();
         tmp.GetAtkType.CreateData(AttackType.Normal, Stats.Strength, unit.myStats.GetStats(Stats.Strength).GetLevel, unit.GetUnitBaseDamage());
         tmp.unitDamage_C    = myStats.NetDamage(tmp.GetAtkType);
         tmp.dataInitialized = true;
     }
     gathererStats.Add(tmp);
 }
Example #20
0
 public override void EndIndividualInteraction(UnitBaseBehaviourComponent unit)
 {
     if (gathererStats.Contains(gathererStats.Find(x => x.unitSaved == unit)))
     {
         gathererStats.Remove(gathererStats.Find(x => x.unitSaved == unit));
         interactingUnit.Remove(unit);
         if (unit.interactWith == this)
         {
             unit.ReceiveOrder(UnitOrder.GenerateIdleOrder());
         }
     }
 }
Example #21
0
 public void Initialize(Stats newName, UnitBaseBehaviourComponent newOwner)
 {
     owner    = newOwner;
     curStats = newName;
     if (statsIconList.Find(x => x.name == newName) != null)
     {
         int idx = statsIconList.FindIndex(x => x.name == newName);
         statImage.sprite = statsIconList[idx].statIcon;
     }
     statsName.text     = curStats.ToString();
     exp.text           = owner.myStats.GetStats(curStats).GetCurrentExperience + "/" + owner.myStats.GetStats(curStats).GetNextLevelExperience;
     expFill.fillAmount = owner.myStats.GetStats(curStats).GetCurrentExperience / owner.myStats.GetStats(curStats).GetNextLevelExperience;
 }
Example #22
0
    public void RemoveUnitToControlled(UnitBaseBehaviourComponent unit)
    {
        if (!controlledUnits.Contains(unit))
        {
            return;
        }

        controlledUnits.Remove(unit);

        Parameters p = new Parameters();

        p.AddParameter <UnitBaseBehaviourComponent>("UnitControlled", unit);
    }
Example #23
0
 public void InitializeSelectedUnits()
 {
     foreach (UnitBaseBehaviourComponent item in unitSelected)
     {
         item.InitializeSelected();
     }
     if (unitSelected[0].unitAffiliation == UnitAffiliation.Controlled)
     {
         manualControlledUnit = unitSelected[0];
         comboComponent.SetUnitDoingCombo(manualControlledUnit);
         manualControlledUnit.InitializeManualSelected();
     }
 }
Example #24
0
 public void SelectObject(UnitAffiliation newAffiliation, UnitBaseBehaviourComponent clickedUnit)
 {
     DeinitializeSelectedUnits();
     unitSelected.Clear();
     selectedTeamAffiliation = newAffiliation;
     unitSelected.Add(clickedUnit);
     InitializeSelectedUnits();
     if (clickedUnit.unitAffiliation == UnitAffiliation.Controlled)
     {
         manualControlledUnit = clickedUnit;
         comboComponent.SetUnitDoingCombo(manualControlledUnit);
     }
 }
Example #25
0
    public void RemoveToUnitControlled(Parameters p)
    {
        UnitBaseBehaviourComponent check = p.GetWithKeyParameterValue <UnitBaseBehaviourComponent>("UnitControlled", null);

        if (check == null)
        {
            return;
        }

        if (fourUnits.Contains(check))
        {
            fourUnits.Remove(check);
        }
        // Check if Player Currently is inGame
        characterHandler.RefreshCharacterHandlers(fourUnits);
    }
Example #26
0
        public void OnTriggerExit(Collider other)
        {
            if (!obtainUnits)
            {
                return;
            }

            if (other.GetComponent <UnitBaseBehaviourComponent>())
            {
                UnitBaseBehaviourComponent tmp = other.GetComponent <UnitBaseBehaviourComponent>();
                if (unitsHit.Contains(tmp))
                {
                    unitsHit.Remove(tmp);
                }
            }
        }
Example #27
0
 public void AdjustUnitListDueToPlayer(UnitBaseBehaviourComponent thisPlayer)
 {
     if (fourUnits != null)
     {
         List <UnitBaseBehaviourComponent> tmp = new List <UnitBaseBehaviourComponent>();
         tmp.Add(thisPlayer);
         foreach (UnitBaseBehaviourComponent item in fourUnits)
         {
             tmp.Add(item);
         }
         fourUnits = tmp;
     }
     else
     {
         fourUnits.Add(thisPlayer);
     }
 }
Example #28
0
    public void SetNewManualUnitControlled(Parameters p)
    {
        UnitBaseBehaviourComponent unitToRepresent = p.GetWithKeyParameterValue <UnitBaseBehaviourComponent>("ManualUnit", null);

        if (unitToRepresent == null)
        {
            return;
        }

        foreach (CharacterInfoHandler item in characterHandlers)
        {
            if (item.unitStats == unitToRepresent.myStats)
            {
                UpdateManualAutoUnits(item);
            }
        }
    }
Example #29
0
    public void RemoveUnitToHandler(UnitBaseBehaviourComponent unit)
    {
        CharacterInfoHandler handler = characterHandlers.Find(x => x.unitStats == unit.myStats);

        if (handler == null)
        {
            return;
        }
        foreach (CharacterInfoHandler item in characterHandlers)
        {
            if (item.unitStats == unit.myStats)
            {
                item.ClearHandler();
                break;
            }
        }
        CountCurrentUnits();
    }
Example #30
0
    public void AddUnitToHandler(UnitBaseBehaviourComponent unit)
    {
        CharacterInfoHandler handler = characterHandlers.Find(x => x.unitStats == unit.myStats);

        if (handler != null)
        {
            return;
        }

        foreach (CharacterInfoHandler item in characterHandlers)
        {
            if (item.unitStats != null)
            {
                item.Initialize(unit.myStats);
                break;
            }
        }
    }