Example #1
0
        private static void EnergyData(Energy energy)
        {
            EditorGUILayout.BeginHorizontal();
            string estr = string.Format(("Add {0} Energy"), energyAddValue);

            if (GUILayout.Button(new GUIContent(estr, estr)))
            {
                energy.Change(energyAddValue);
            }
            estr = string.Format(("Remove {0} Energy"), energyRemoveValue);
            if (GUILayout.Button(new GUIContent(estr, estr)))
            {
                energy.Change(-energyRemoveValue);
            }
            estr = "Set to max energy";
            if (GUILayout.Button(new GUIContent(estr, estr)))
            {
                energy.Change(float.MaxValue);
            }
            EditorGUILayout.EndHorizontal();
        }
Example #2
0
        public void Action(int tilesMatched, TileType tileType, Level level, bool manuallyMatched)
        {
            if (tileType == TileType.cog)
            {
                Energy.Change(tilesMatched * 5 + (tilesMatched - 3) * 10);
                SoundManager.match.Play();
            }
            else if (Energy.Value > 10 || !manuallyMatched)
            {
                SoundManager.match.Play();
                if (manuallyMatched)
                {
                    Energy.Change(-10);
                }

                if (tileType == TileType.shoot && Weapons[SelectedWeapon].Disabled < 0)
                {
                    KnockBack = 3;
                    Weapons[SelectedWeapon].Method(this, Weapons[SelectedWeapon], tilesMatched, level, false);
                }

                if (tileType == TileType.left && ShipLocation != Location.left)
                {
                    MoveLeft += 20 * tilesMatched;
                }

                if (tileType == TileType.right && ShipLocation != Location.right)
                {
                    MoveRight += 20 * tilesMatched;
                }

                if (tileType == TileType.shield && ShipShield.Value != ShipShield.Width)
                {
                    ShipShield.Change((ShipShield.ShieldHeal / 3) * tilesMatched);
                }
            }
            else
            {
                level.CombatText("NOT ENOUGH ENERGY!");
                SoundManager.notEnoughEnergy.Play();
            }
        }
Example #3
0
        void Update()
        {
            if (target == null)
            {
                target = Defult;
            }

            Retarget();


            if (run == true && wander == false)
            {
                if (My_Energy.Amount >= 20)
                {
                    RaycastHit forwardhit;
                    float      setY = gameObject.transform.position.y;

                    if (Physics.Raycast(transform.position, transform.forward, out forwardhit, 50, 1, QueryTriggerInteraction.Ignore))
                    {
                        if (hitForward.transform != transform)
                        {
                            Debug.DrawLine(transform.position, hitForward.point, Color.blue);
                            if (!hitForward.collider.bounds.Contains((hitForward.point + gameObject.transform.forward * 50)))
                            {
                                Defult.transform.position     = hitForward.point + gameObject.transform.forward * 50;
                                gameObject.transform.position = new Vector3(gameObject.transform.position.x, 1, gameObject.transform.position.z);
                                gameObject.transform.position = Defult.transform.position;
                            }
                            else
                            {
                                Defult.transform.position = hitForward.point;
                                if (bounding.bounds.Contains(Defult.transform.position))
                                {
                                    gameObject.transform.position = Defult.transform.position;
                                }
                                else
                                {
                                    Defult.transform.position     = new Vector3(bounding.bounds.center.x, 1, bounding.bounds.center.z);
                                    gameObject.transform.position = new Vector3(bounding.bounds.center.x, 1, bounding.bounds.center.z);
                                }
                            }
                        }
                    }
                    else
                    {
                        gameObject.transform.position = gameObject.transform.position + gameObject.transform.forward * 50;
                        gameObject.transform.position = new Vector3(gameObject.transform.position.x, 1, gameObject.transform.position.z);
                        if (bounding.bounds.Contains(Defult.transform.position))
                        {
                            gameObject.transform.position = Defult.transform.position;
                        }
                        else
                        {
                            Defult.transform.position     = new Vector3(bounding.bounds.center.x, 1, bounding.bounds.center.z);
                            gameObject.transform.position = new Vector3(bounding.bounds.center.x, 1, bounding.bounds.center.z);
                        }
                    }
                    My_Energy.Change(-20);
                    My_Body.Ability2();
                }
            }
            else if (attack == true)
            {
                if (target != Defult)
                {
                    if (My_Energy.Amount >= 5)
                    {
                        if (AttackTimmer >= 1)
                        {
                            My_Body.Ability1();
                            target.GetComponent <Health>().Change(damage, target);
                            My_Energy.Change(-5);
                            AttackTimmer = 0;
                        }
                        else
                        {
                            AttackTimmer = AttackTimmer + Time.deltaTime;
                        }
                    }
                }
                else
                {
                    attack = false;
                }
            }
        }