Ejemplo n.º 1
0
    public void RefreshAll(UnitCore snapshot)
    {
        for (int count = 0; count < elements.Count; count++)
        {
            float newAmount = 0;
            switch (elements[count].resource)
            {
            case Defs.ResourceTypes.Health:
                newAmount = snapshot.Health.PCT();
                break;

            case Defs.ResourceTypes.Stamina:
                newAmount = snapshot.Stamina.PCT();
                break;
            }
            elements[count].fill.fillAmount = newAmount;

            if (elements[count].reductionAnimation)
            {
                if (elements[count].lastReportedVal > newAmount)
                {
                    elements[count].sinceLastLoss = 1.2f;
                }
                else
                {
                    elements[count].sinceLastLoss = 0;
                }
            }

            elements[count].lastReportedVal = newAmount;
        }
    }
Ejemplo n.º 2
0
    public void UpdateGuideLines(UnitCore target)
    {
        for (int count = 0; count < elements.Count; count++)
        {
            if (elements[count].guideLines >= 100)
            {
                int   lines   = 0;
                float spacing = 0;
                switch (elements[count].resource)
                {
                case Defs.ResourceTypes.Health:
                    lines = Mathf.FloorToInt(target.Health.Max / UI_Styles.i.unitHUD.guideLineSpacing);
                    break;

                case Defs.ResourceTypes.Stamina:
                    lines = Mathf.FloorToInt(target.Stamina.Max / UI_Styles.i.unitHUD.guideLineSpacing);
                    break;
                }
                spacing = ((elements[count].fill.preferredWidth / 2) / lines);
                Transform             guideLinesT = elements[count].root.GetChild(2);
                HorizontalLayoutGroup targetGroup = guideLinesT.GetComponent <HorizontalLayoutGroup>();
                targetGroup.spacing = spacing;
                for (int instance = 0; instance < lines; instance++)
                {
                    Instantiate(guideLine, guideLinesT);
                }
            }
        }
    }
Ejemplo n.º 3
0
    void Start()
    {
        anim       = GetComponent <Animator>();
        unitCore   = GetComponent <UnitCore>();
        playerCore = GetComponent <PlayerCore>();
        states     = GetComponent <HERO_StateController>();

        if (isLocalPlayer && isClient)
        {
            //HUD
            HUDPointer        = GameObject.Find("HUD/WeaponCore").GetComponent <Image>();
            HUDBackground     = HUDPointer.transform.GetChild(0).GetComponent <Image>();
            HUDBar[0]         = HUDBackground.transform.GetChild(0).GetComponent <Image>();
            HUDBar[1]         = HUDBackground.transform.GetChild(1).GetComponent <Image>();
            HUDItemBackground = HUDPointer.transform.GetChild(1).GetComponent <CanvasGroup>();
            HUDItemBar        = HUDItemBackground.transform.GetChild(0).GetComponent <Image>();

            //Cursor
            Cursor.visible   = false;
            Cursor.lockState = CursorLockMode.Confined;
        }

        //Test Weapons
        EquipWeapon(MasterListDatabase.i.FetchItem(0), 0);
        EquipWeapon(MasterListDatabase.i.FetchItem(2), 1);
    }
Ejemplo n.º 4
0
 //This function will choose if the target remains on the field.
 public void Action_IfDeadKillUnit(UnitCore target)
 {
     if (target.health <= 0)
     {
         target.death();
     }
 }
        public void MoveUnit(UnitPresentation unitPresentation, Vector2Int position)
        {
            if (unitPresentation is null)
            {
                throw new ArgumentNullException(nameof(unitPresentation));
            }
            if (!Contains(unitPresentation))
            {
                throw new InvalidOperationException($"There is no unit {unitPresentation}!");
            }
            var onPosition = this[position];

            if (onPosition != null)
            {
                if (onPosition != unitPresentation)
                {
                    throw new InvalidOperationException($"Position {position} is already occupied by {onPosition}.");
                }
            }
            else
            {
                UnitCore unit        = presentationsToUnits[unitPresentation];
                var      oldPosition = unitsToPositions[unit];
                positionsToUnits.Remove(oldPosition);
                unitsToPositions[unit]     = position;
                positionsToUnits[position] = unit;
                state = state.BuildTransition(unitPresentation);
            }
        }
Ejemplo n.º 6
0
 public void AddState(UnitCore causer, State newState)
 {
     if (newState.independent)
     {
         CreateNewInstanceOfState(causer, newState);
     }
     else
     {
         if (!activeStates.Contains(newState))
         {
             CreateNewInstanceOfState(causer, newState);
         }
         else
         {
             if (newState.maxStacks != 0 && properties[activeStates.IndexOf(newState)].stacks != newState.maxStacks)
             {
                 properties[activeStates.IndexOf(newState)].stacks++;
             }
             else
             {
                 properties[activeStates.IndexOf(newState)].duration = newState.duration;
             }
         }
     }
 }
Ejemplo n.º 7
0
 public void AddStates(UnitCore causer, List <State> newStates)
 {
     for (int count = 0; count < newStates.Count; count++)
     {
         if (newStates[count].independent)
         {
             CreateNewInstanceOfState(causer, newStates[count]);
         }
         else
         {
             if (!activeStates.Contains(newStates[count]))
             {
                 CreateNewInstanceOfState(causer, newStates[count]);
             }
             else
             {
                 if (newStates[count].maxStacks != 0 && properties[activeStates.IndexOf(newStates[count])].stacks != newStates[count].maxStacks)
                 {
                     properties[activeStates.IndexOf(newStates[count])].stacks++;
                 }
                 else
                 {
                     properties[activeStates.IndexOf(newStates[count])].duration = newStates[count].duration;
                 }
             }
         }
     }
 }
Ejemplo n.º 8
0
 //This function will choose if the target remains on the field.
 private void Action_IfDeadKillUnit(UnitCore target)
 {
     if (target.health < 0)
     {
         target.death();
     }
 }
Ejemplo n.º 9
0
    public void RegisterBlock(GameObject hit)
    {
        Debug.Log("Blocked!");
        UnitCore target = hit.GetComponent <UnitCore>();

        target.RunEffector(new Source(caller.unitCore, MasterListDatabase.i.FetchItem(itemID), caller), effector, true);
    }
Ejemplo n.º 10
0
Archivo: AgentX.cs Proyecto: s76/testAI
    void Awake()
    {
        arounds = new Collider[0];

        agent = GetComponent<NavMeshAgent> ();
        path  = new NavMeshPath();
        core = GetComponent<UnitCore> ();
    }
Ejemplo n.º 11
0
 public void StartSlowMotion(UnitCore victim)
 {
     update = false;
     StartCoroutine(CameraControl.i.TargetTemp(victim.transform, delay * 0.75f));
     Time.timeScale      = slowdownFactor;
     Time.fixedDeltaTime = Time.timeScale * 0.02f;
     StartCoroutine(Delay());
 }
Ejemplo n.º 12
0
 //Checks if a unit's health is in good enough standing to retaliate.
 //Further conditions should be added here specific to retaliation.
 public bool check_retaliate(UnitCore target)
 {
     if (target.health > 0)
     {
         canRetaliate = true;
     }
     return(canRetaliate);
 }
Ejemplo n.º 13
0
    public override void onUse(Waypoint Current, GameObject CallingUnit, GameObject Target)
    {
        heal = Random.Range(0.2f, 0.3f) * CallingUnit.GetComponent <UnitCore>().health;
        UnitCore target_UnitCore = Target.GetComponent <UnitCore>();

        Action_ModifyTargetHealth((int)heal, target_UnitCore);
        Action_SendUIColor(target_UnitCore, getColor());
    }
Ejemplo n.º 14
0
    void OnEnable()
    {
        music      = GameObject.Find("GameController").GetComponent <HERO_MusicController>();
        unitCore   = GetComponent <UnitCore>();
        inv        = GetComponent <PlayerInventory>();
        weaponCore = GetComponent <WeaponCore>();

        regionMaster = GameObject.Find("Regions").transform;

        //Ability
        actionBarT = GameObject.Find("UI/HUD/ActionBar").transform;

        if (isClient)
        {
            for (int count = 0; count < 5; count++)
            {
                abilityKeys.Add(Binds.i.GetBind("Skill " + (count + 1)).key);
            }

            for (int count = 0; count < 10; count++)
            {
                itemKeys.Add(Binds.i.GetBind("Item " + (count + 1)).key);
            }
        }

        //Mount
        mountGroup = GameObject.Find("UI/HUD/ChannelBack").GetComponent <CanvasGroup>();
        mountBar   = GameObject.Find("UI/HUD/ChannelBack/ChannelBarBack/ChannelBar").GetComponent <Image>();

        //Now pass all required values
        if (isLocalPlayer)
        {
            UI_HUD.i.target     = GetComponent <UnitCore>();
            UI_HUD.i.playerCore = UI_CharacterMenu.i.playerCore = this;
        }

        if (isServer)
        {
            availableSlots = PlayerClassToSlots(playerClass);

            for (int count = 0; count < 5; count++)
            {
                if (!equippedAbilities[count].equipped)
                {
                    RpcHUDPingAbility(count, Defs.AbilityMode.Level);
                }
            }

            int[]    skills = new int[5];
            string[] keys   = new string[5];
            for (int count = 0; count < 5; count++)
            {
                keys[count]   = abilityKeys[count].ToString();
                skills[count] = -1;
            }
            RpcActionBar_Rebuild(skills, keys);
        }
    }
Ejemplo n.º 15
0
    //If the unit is in good standing health wise, then it will retaliate against the recivingUnit.
    public void Attack_Retaliation(UnitCore RetaliatingUnit, UnitCore recivingUnit)
    {
        bool canTargetRetaliate = check_retaliate(RetaliatingUnit);

        if (canTargetRetaliate)
        {
            Retaliation(RetaliatingUnit, recivingUnit);
        }
    }
Ejemplo n.º 16
0
    void RegisterHit(GameObject hit)
    {
        //Audio
        AudioController.i.CmdPlay3DItemSound(caller.playerCore.currentLocation, caller.hands[hand].equipped.ID, Defs.ItemSound.HitSound, transform.position, 0.8f, 10, 30, 0.85f, 1.15f);

        UnitCore target = hit.GetComponent <UnitCore>();

        target.RunEffector(new Source(caller.unitCore, MasterListDatabase.i.FetchItem(itemID), caller), effector, false);
    }
Ejemplo n.º 17
0
 void Start()
 {
     //Get Components
     mainCam  = Camera.main;
     cam      = mainCam.GetComponent <CameraControl>();
     unitCore = GetComponent <UnitCore>();
     player   = GetComponent <CharacterController>();
     anim     = GetComponent <Animator>();
     debug    = GameObject.Find("DEBUG!").GetComponent <TextMeshProUGUI>();
 }
Ejemplo n.º 18
0
    IEnumerator debugwaitAttacker()
    {
        yield return(new WaitForSeconds(0.5f));

        UnitCore thisUnit = MainUnit.GetComponent <UnitCore>();

        UnitCore.targettingPackage package = thisUnit.getTargetandTactic();
        package.SelectedTactic.onUse(currentNode, MainUnit, package.TargetList);
        StartCoroutine(debugwaitDefender());
    }
Ejemplo n.º 19
0
    //Check if the target is under 0 health.
    private bool Check_isDead(UnitCore target)
    {
        bool isDead = false;

        if (target.health < 0)
        {
            isDead = true;
        }
        return(isDead);
    }
Ejemplo n.º 20
0
 public void ManageUnitCores(UnitCore target, bool register)
 {
     if (register)
     {
         unitCores.Add(target);
     }
     else
     {
         unitCores.Remove(target);
     }
 }
Ejemplo n.º 21
0
 public void RegisterBlock(GameObject hit)
 {
     if (!hitTargets.Contains(hit.GetComponent <NetworkIdentity>().netId))
     {
         hitTargets.Add(hit.GetComponent <NetworkIdentity>().netId);
         Debug.Log("Blocked!");
         UnitCore target = hit.GetComponent <UnitCore>();
         target.RunEffector(new Source(caller.unitCore, MasterListDatabase.i.FetchItem(itemID), caller), effector, true);
         Destroy(gameObject);
     }
 }
Ejemplo n.º 22
0
    //Target: Specific
    //Handles retaliation
    private void Retaliation(UnitCore retaliatingUnit, UnitCore recivingUnit)
    {
        int damage = get_RetaliationDamage(retaliatingUnit);

        if (check_retaliate(retaliatingUnit))
        {
            Attack_Target(damage, recivingUnit);
            Action_UpdateUIHealth(recivingUnit);
            Action_SendUIColor(recivingUnit, new Color32(255, 255, 51, 255));
            Action_IfDeadKillUnit(recivingUnit);
        }
    }
Ejemplo n.º 23
0
Archivo: Barier.cs Proyecto: s76/testAI
    public void TestIfBarierSuitableToHide( UnitCore unit, Vector3 precalculated_toEnemyVector, ref float global_min, ref Barier barier )
    {
        var unit_position = unit.transform.position;

        //!!! CAUTION !!!
        // only work with 4 side points and 4 conner points !!!!
        float local_min = global_min;
        bool min_changed = false;
        Vector3 closest = Vector3.zero;
        Vector3 tmp;
        tmp = side_points[0].value - unit_position;
        if ( tmp.magnitude < global_min ) {
            closest = side_points[0].value;
            global_min = tmp.magnitude;
            min_changed = true;
        }
        foreach (var r in side_points[0].closest_conner_points) {
            tmp = r - unit_position;
            if ( tmp.magnitude < local_min ) {
                closest = r;
                local_min = tmp.magnitude;
                min_changed = true;
            }
        }

        tmp = side_points[2].value - unit_position;
        if ( tmp.magnitude < local_min ) {
            closest = side_points[2].value;
            local_min = tmp.magnitude;
            min_changed = true;
        }
        foreach (var r in side_points[2].closest_conner_points) {
            tmp = r - unit_position;
            if ( tmp.magnitude < local_min ) {
                closest = r;
                local_min = tmp.magnitude;
                min_changed = true;
            }
        }
        //!!! END CAUTION !!!

        if (min_changed) {
            if ( Physics.Linecast(closest, unit.transform.position, walls_mask) ) return;

            // if we must run over enemy to reach the barier then no
            if (Vector3.Angle (precalculated_toEnemyVector, closest -unit_position) > 50f) {
                barier = this;
                global_min = local_min;
            }
        }
    }
Ejemplo n.º 24
0
    //Returns a list of targets that are opposed to the CallingUnit.
    public List <GameObject> get_TargetList(Waypoint CurrentWaypoint, UnitCore CallingUnit)
    {
        List <GameObject> targetList;

        if (CallingUnit.faction == "Player")
        {
            targetList = CurrentWaypoint.Enemies;
        }
        else
        {
            targetList = CurrentWaypoint.Allies;
        }
        return(targetList);
    }
Ejemplo n.º 25
0
    public void RegisterHit(GameObject hit)
    {
        //Audio
        AudioController.i.CmdPlay3DItemSound(caller.playerCore.currentLocation, itemID, Defs.ItemSound.HitSound, transform.position, 0.8f, 10, 30, 0.85f, 1.15f);

        UnitCore target = hit.GetComponent <UnitCore>();

        target.RunEffector(new Source(caller.unitCore, MasterListDatabase.i.FetchItem(itemID)), effector, false);
        if (targetLimit != 0)
        {
            targetsHit--;
            if (targetsHit == 0)
            {
                Destroy(gameObject);
            }
        }
    }
        // Modifying methods.

        public void AddUnit(UnitCore unit, Vector2Int position)
        {
            if (unit is null)
            {
                throw new ArgumentNullException(nameof(unit));
            }
            var onPosition = this[position];

            if (onPosition != null)
            {
                throw new InvalidOperationException($"Position {position} is already occupied by {onPosition}.");
            }
            unit = unit.Clone();
            unit.Connect(Presentation);
            presentationsToUnits[unit.Presentation] = unit;
            unitsToPositions[unit]     = position;
            positionsToUnits[position] = unit;
            state = state.BuildTransition(unit.Presentation);
        }
Ejemplo n.º 27
0
    void CreateNewInstanceOfState(UnitCore causer, State newState)
    {
        activeStates.Add(newState);

        //Search for awake effects
        List <State.Effect> awakeEffects = new List <State.Effect>();

        for (int count = 0; count < newState.effects.Count; count++)
        {
            if (newState.effects[count].awakeEffect)
            {
                awakeEffects.Add(newState.effects[count]);
            }
        }

        //Create Duration List
        Properties newList = new Properties();

        //Causer
        newList.causer = causer;

        //Apply awake effects
        for (int count = 0; count < awakeEffects.Count; count++)
        {
            RunEffect(properties[count].causer, activeStates[count], awakeEffects[count].effector);
        }


        //Setup duration
        newList.duration = newList.durationMax = newState.duration;

        //Setup ticks
        newList.tick = new List <int>(newState.effects.Count);
        for (int count = 0; count < newState.effects.Count; count++)
        {
            newList.tick.Add(newState.effects[count].tickLength);
        }

        newList.stacks = 1;

        properties.Add(newList);
    }
Ejemplo n.º 28
0
        // Support method.

        private UnitCore BuildUnit(System.Random random, Vector2Int position, MapPresentation map, ref int added)
        {
            // Initialize unit.
            UnitCore unit;

            if (UnitTemplates == null || UnitTemplates.Length == 0)
            {
                unit = new UnitCore();
            }
            else
            {
                unit = UnitTemplates[random.Next(UnitTemplates.Length)].Clone();
            }

            // Place unit.
            unit.Name = $"Unit {added++}";
            Vector3 point = new Vector3(position.x, map[position].Height, position.y);

            unit.Move(new MovementAction(point - unit.Body.Position, adjustVelocity: false));
            return(unit);
        }
        public UnitCore RemoveUnit(UnitPresentation unitPresentation)
        {
            if (unitPresentation is null)
            {
                throw new ArgumentNullException(nameof(unitPresentation));
            }
            if (!Contains(unitPresentation))
            {
                throw new InvalidOperationException($"There is no unit {unitPresentation}!");
            }
            UnitCore unit = presentationsToUnits[unitPresentation];

            unit.Disconnect();
            presentationsToUnits.Remove(unitPresentation);
            var position = unitsToPositions[unit];

            positionsToUnits.Remove(position);
            unitsToPositions.Remove(unit);
            state = state.BuildTransition(unitPresentation);
            return(unit);
        }
Ejemplo n.º 30
0
//We need to really consider just what we're going to do for attacks.
//Tactics should be able to target ally units

    //Target: Random Enemy
    //Light Damage, No retaliate, Yellow UI
    public void LightAttack(Waypoint CurrentWaypoint, UnitCore CallingUnit, int NumberOfTargets, bool canRetaliate)
    {
        //NEW SETUP. Calculate everything first, and then send an order sequence to the camera so that it can do it's job.
        CleanBools();
        List <GameObject> targetList = get_TargetList(CurrentWaypoint, CallingUnit);
        List <UnitCore>   target = get_RandomTarget(targetList, NumberOfTargets);
        int damage, index = 0;

        foreach (UnitCore troop in target)
        {
            index++;
            damage = get_DamageLight(CallingUnit);
            Attack_Target(damage, troop);
            if (canRetaliate)
            {
                Attack_Retaliation(troop, CallingUnit);
            }
            if (Check_isDead(CallingUnit))
            {
                break;                                          //If the retaliation marks the unit for death, then break out of loop.
            }
        }


        //So now what do we actually have?

        /*All of these units have had their health reduced, but only that. We know where the loop stopped.
         *
         * Let's assume the countine is a required element. We don't know what the end system will be but we can describe some aspects:
         * -Countine ladder downwards
         * -Modular code
         * -Calculates things inside the countine
         *
         * //OUTSIDE COUNTINE
         * -Targets can be calculated outside.
         * -Who retaliates?
         *
         *
         * -*/
    }
Ejemplo n.º 31
0
 /* ########################## core mono functions ######################## */
 void Awake()
 {
     reactor = GetComponent<Reactor> ();
     core = GetComponent<UnitCore> ();
 }
Ejemplo n.º 32
0
 void Start()
 {
     unitCore = GetComponent <UnitCore>();
 }
Ejemplo n.º 33
0
 void RunEffect(UnitCore causer, State state, Effector targetEffect)
 {
     unitCore.RunEffector(new Source(causer, state), targetEffect, false);
 }
Ejemplo n.º 34
0
 public void RegisterUnit( UnitCore unit )
 {
     var l = unit.side == UnitSide.Side01 ? side01 : side02;
     if ( !l.Contains(unit) ) l.Add (unit);
 }