Example #1
0
 public override void UpdateAction(AIBrain brain)
 {
     OnStart(brain.character);
     OnEnd(brain.character);
 }
Example #2
0
        // move the selected characters around a given point, spacing them in a circle
        void MoveSquadToPoint(Vector3 pos)
        {
            Vector3            centroid = Vector3.zero;
            List <SquadMember> selected = new List <SquadMember>();

            foreach (SquadMember sm in squad)
            {
                if (sm.selected)
                {
                    AIBrain brain = sm.GetComponent <AIBrain>();
                    brain.SetRootNode(null);
                    brain.target           = null;
                    brain.character.target = null;
                    centroid += sm.transform.position;
                    selected.Add(sm);
                }
            }

            // we now have a list of all selected characters and a central point
            // if theres one or less, move them to the point we clicked
            if (selected.Count <= 1)
            {
                foreach (SquadMember sm in selected)
                {
                    sm.MoveTo(pos);
                    moveReticle[0].SetActive(true);
                    moveReticle[0].transform.position   = pos;
                    moveReticle[0].transform.localScale = Vector3.one;
                }
            }
            else
            {
                // for two or more, sort in order of  angle from the centroid, so we can arrange them around the circle
                centroid /= (float)selected.Count;
                foreach (SquadMember sm in selected)
                {
                    sm.SetDeltaPos(sm.transform.position - centroid);
                }
                selected.Sort(delegate(SquadMember a, SquadMember b)
                {
                    return(a.deltaAngle.CompareTo(b.deltaAngle));
                });

                // copy the angles into an array and find the best spread for them
                float[] angles = new float[selected.Count];
                for (int i = 0; i < selected.Count; i++)
                {
                    angles[i] = selected[i].deltaAngle;
                }
                SpreadAngles(angles);

                // move the characters to positions around a circle centred on the point
                int index = 0;
                for (int i = 0; i < selected.Count; i++)
                {
                    Vector3 targetPos = pos + new Vector3(Mathf.Cos(angles[i]), 0, Mathf.Sin(angles[i])) * squadRadius;
                    moveReticle[i].SetActive(true);
                    moveReticle[i].transform.position   = targetPos;
                    moveReticle[i].transform.localScale = Vector3.one;
                    selected[i].MoveTo(targetPos);
                    index++;
                }
            }
        }
Example #3
0
        // Use this for initialization
        void Start()
        {
            animator    = GetComponent <Animator>();
            brain       = GetComponent <AIBrain>();
            audioSource = GetComponent <AudioSource>();
            if (audioSource == null)
            {
                audioSource = gameObject.AddComponent <AudioSource>();
            }
            InitProp();

            fadeTime = 10.0f;

            for (int i = 0; i < RPGSettings.BasicDamageTypesCount; i++)
            {
                stats[RPGSettings.GetDamageStat((RPGSettings.DamageType)(1 << i))] = new Stat();
            }
            // healing damage boost does make sense
            stats[RPGSettings.GetDamageStat(RPGSettings.DamageType.Healing)] = new Stat();

            // special starting values and non-buffs go here
            stats[RPGSettings.StatName.Energy.ToString()] = new Stat(maxEnergy, false);
            stats[RPGSettings.StatName.Charge.ToString()] = new Stat(0, false);

            // all others are normal buffable stats
            RPGSettings.StatName numStats = (RPGSettings.StatName)System.Enum.GetNames(typeof(RPGSettings.StatName)).Length;
            for (RPGSettings.StatName i = RPGSettings.StatName.EnergyRegen; i <= numStats; i++)
            {
                if (!stats.ContainsKey(i.ToString()))
                {
                    stats[i.ToString()] = new Stat();
                }
            }

            energyStat = stats[RPGSettings.StatName.Energy.ToString()];

            RPGSettings.instance.SetupCharacter(this);

            tpc = GetComponent <ThirdPersonCharacter>();
            if (tpc)
            {
                baseJumpPower = tpc.m_JumpPower;
            }

            Transform beamChild = transform.Find("Beam");

            if (beamChild == null)
            {
                GameObject go = ObjectFactory.GetObject(RPGSettings.instance.beam);
                beamChild               = go.transform;
                beamChild.parent        = transform;
                beamChild.localPosition = Vector3.zero;
            }
            if (beamChild)
            {
                beam = beamChild.GetComponent <BeamRenderer>();
            }

            ApplyPassives();

            //create a tragetting reticle and disable it
            reticle = ObjectFactory.GetObject(RPGSettings.instance.reticle);
            reticle.transform.parent        = transform;
            reticle.transform.localPosition = Vector3.zero;
            reticle.name = "reticle";
            reticle.SetActive(false);

            bodyParts[BodyPart.Root]         = transform;
            bodyParts[BodyPart.Head]         = head;
            bodyParts[BodyPart.Chest]        = chest;
            bodyParts[BodyPart.LeftHand]     = leftHand;
            bodyParts[BodyPart.RightHand]    = rightHand;
            bodyParts[BodyPart.LeftFoot]     = leftFoot;
            bodyParts[BodyPart.RightFoot]    = rightFoot;
            bodyParts[BodyPart.LeftForeArm]  = leftForeArm;
            bodyParts[BodyPart.RightForeArm] = rightForeArm;
            bodyParts[BodyPart.LeftBicep]    = leftBicep;
            bodyParts[BodyPart.RightBicep]   = rightBicep;
            bodyParts[BodyPart.LeftThigh]    = leftThigh;
            bodyParts[BodyPart.LightThigh]   = rightThigh;
            bodyParts[BodyPart.LeftCalf]     = leftCalf;
            bodyParts[BodyPart.RightCalf]    = rightCalf;
            bodyParts[BodyPart.Waist]        = waist;
            bodyParts[BodyPart.Weapon1]      = weapon1;
            bodyParts[BodyPart.Weapon2]      = weapon2;
        }