コード例 #1
0
        /// <summary>
        /// Find translted vehicle name. Return null, if nothing is found.
        /// </summary>
        /// <param name="tank"></param>
        /// <returns></returns>
        public static string findName(TankStats tank)
        {
            string fixedTankName = TankNameHelper.IDRegex.Replace(tank.Name, "").Replace(' ', '_');

            if (subfixes.IsMatch(fixedTankName))
            {
                fixedTankName = subfixes.Replace(fixedTankName, "");
            }

            // 1 search for tankID_short
            // 2 search for tankName_short
            // 3 search for tankID
            // 4 search for tankName

            string[] search = new string[] {
                tank.Id + "_short",
                fixedTankName + "_short",
                tank.Id,
                fixedTankName,
            };

            foreach (Catalog catalog in catalogs)
            {
                foreach (string key in search)
                {
                    string translation = catalog.GetStringDefault(key, null);
                    if (translation != null)
                    {
                        return(translation);
                    }
                }
            }

            return(null);
        }
コード例 #2
0
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        tank = animator.gameObject;

        navMeshAgent = tank.GetComponent <NavMeshAgent>();
        tankStats    = tank.GetComponent <TankStats>();

        chaseTank = tankStats.tankToSee;
    }
コード例 #3
0
ファイル: PatrolAction.cs プロジェクト: andreabefuen/sprint-1
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        tank         = animator.gameObject;
        navMeshAgent = tank.GetComponent <NavMeshAgent>();
        tankStats    = tank.GetComponent <TankStats>();

        shootableMask = LayerMask.GetMask("Shootable");
        anim          = animator;
    }
コード例 #4
0
        public static string findName(TankStats tank)
        {
            string key = tank.Nation + ":" + tank.Id;

            if (nameList.ContainsKey(key))
            {
                return(nameList[key]);
            }
            return(null);
        }
コード例 #5
0
        protected void CreateIconSet(IconSet iconSet, TankStats tankStats, string parentPath = null)
        {
            // generate base icon for set, and thne pass it to all other versions
            string iconPath = iconSet.Generate(tankStats, parentPath);

            foreach (IconSet iconVersion in iconSet.getVersions())
            {
                CreateIconSet(iconVersion, tankStats, iconPath);
            }
        }
コード例 #6
0
 public void Apply(Layer layer, TankStats tankStats)
 {
     try
     {
         layer(g, tankStats);
     }
     catch (Exception e)
     {
         Console.WriteLine("Error during appling layer: " + layer.Target);
         Console.WriteLine(e.Message + "\n");
     }
 }
コード例 #7
0
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        tank = animator.gameObject;

        tankStats = tank.GetComponent <TankStats>();
        chaseTank = tankStats.tankToSee;


        shootableMask = LayerMask.GetMask("Shootable");

        timeBetweenFires = tankStats.timeBetweenFire;
    }
コード例 #8
0
    private void OnTriggerEnter(Collider other)
    {
        // Collect all the colliders in a sphere from the shell's current position to a radius of the explosion radius.
        Collider[] colliders = Physics.OverlapSphere(transform.position, m_ExplosionRadius, m_TankMask);

        // Go through all the colliders...
        for (int i = 0; i < colliders.Length; i++)
        {
            // ... and find their rigidbody.
            Rigidbody targetRigidbody = colliders[i].GetComponent <Rigidbody>();

            // If they don't have a rigidbody, go on to the next collider.
            if (!targetRigidbody)
            {
                continue;
            }

            // Add an explosion force.
            targetRigidbody.AddExplosionForce(m_ExplosionForce, transform.position, m_ExplosionRadius);

            // Find the TankHealth script associated with the rigidbody.
            TankStats tankStats = targetRigidbody.GetComponent <TankStats>();

            // If there is no TankHealth script attached to the gameobject, go on to the next collider.
            if (!tankStats)
            {
                continue;
            }

            // Calculate the amount of damage the target should take based on it's distance from the shell.
            //float damage = CalculateDamage(targetRigidbody.position);

            // Deal this damage to the tank.
            //tankStats.TakeDamage(2.5f);
            Debug.Log("aucn");
        }

        // Unparent the particles from the shell.
        m_ExplosionParticles.transform.parent = null;

        // Play the particle system.
        m_ExplosionParticles.Play();

        // Play the explosion sound effect.
        m_ExplosionAudio.Play();

        // Once the particles have finished, destroy the gameobject they are on.
        ParticleSystem.MainModule mainModule = m_ExplosionParticles.main;
        Destroy(m_ExplosionParticles.gameObject, mainModule.duration);

        // Destroy the shell.
        Destroy(gameObject, 2f);
    }
コード例 #9
0
        public static string findName(TankStats tank, string fallBackName)
        {
            string key = tank.Nation + ":" + tank.Id;

            if (nameList.ContainsKey(key))
            {
                return(nameList[key]);
            }

            Console.WriteLine("No custom name for key: " + key + "\n");
            //Console.WriteLine("Enter short name:");
            saveNewShortNames(key, fallBackName);

            return(null);
        }
コード例 #10
0
        /// <summary>
        /// Generate icon file based on given stats and parent icon, if set.
        /// </summary>
        /// <param name="tankStats"></param>
        /// <param name="parentPath"></param>
        /// <returns>Output path to icon file.</returns>
        public string Generate(TankStats tankStats, string parentPath = null)
        {
            string outputFile = Path.Combine(OutputPathIcon, tankStats.FileName);

            // create / load icon file
            using (Icon icon = parentPath == null ? new Icon() : new Icon(parentPath))
            {
                // aply layers
                foreach (Layer layer in Layers)
                {
                    icon.Apply(layer, tankStats);
                }

                // save to file
                icon.Save(outputFile);
            }

            return(outputFile);
        }
コード例 #11
0
        protected static string customName(TankStats tank, int maxWidth, string fallBackName)
        {
            // 3 custom name

            // if custom name doesnt exist, create it and set it to prevuisly name, od ID
            string name = CustomNames.findName(tank, fallBackName);

            if (name == null)
            {
                return("");
            }

            // if custom name is too long, show warning
            if (isTextToLong(name, maxWidth))
            {
                Console.WriteLine("Custom name is too long: " + name);
                name = "";
            }

            return(name);
        }
コード例 #12
0
        protected static string translatedName(TankStats tank, int maxWidth, string fallBackName)
        {
            // 2 transalted name

            string name = WgTranslator.findName(tank);

            // if no translated name found, use custom name
            if (name == null)
            {
                //Console.WriteLine("No translation for: " + tank.Id);
                return(customName(tank, maxWidth, fallBackName + "_no_translation"));
            }

            // if translated name is too long, use custom name
            if (isTextToLong(name, maxWidth))
            {
                //Console.WriteLine("Translated name is to long: " + tank.Id);
                return(customName(tank, maxWidth, name + "_transaltion_to_long"));
            }

            return(name);
        }
コード例 #13
0
    private void CheckForHit()
    {
        RaycastHit[] hits = Physics.RaycastAll(new Ray(_prevPos, (transform.position - _prevPos).normalized), (transform.position - _prevPos).magnitude);

        for (int i = 0; i < hits.Length; i++)
        {
            Transform currHit = hits[i].collider.transform;
            bool      target  = currHit.root.tag.Contains("Target") || currHit.tag.Contains("Target");
            bool      pass    = currHit.tag.Contains("Pass");

            if (target && !pass)
            {
                String[] Tags = Regex.Split(currHit.tag + currHit.root.tag, @"(?<!^)(?=[A-Z])").Distinct().ToArray(); //Gets all tags split on upppercase
                foreach (String tag in Tags)
                {
                    switch (tag)
                    {
                    case "Tank":
                        TankStats tankStats = currHit.root.gameObject.GetComponent <TankStats>();
                        tankStats.triggerHit(gameObject);
                        break;

                    case "Object":
                        ObjectStats objectStats = currHit.gameObject.GetComponent <ObjectStats>();
                        objectStats.TriggerHit(gameObject);
                        break;

                    case "Npc":
                        NPCStats NPCStats = currHit.root.gameObject.GetComponent <NPCStats>();
                        NPCStats.TriggerHit(gameObject);
                        break;
                    }
                }

                Destroy(gameObject);
                return;
            }
        }
    }
コード例 #14
0
        public static string findShortName(TankStats tank, int maxWidth)
        {
            // 1 use regular tank name
            string name = tank.Name;

            string forceCustom = forceCustomName(tank);

            if (forceCustom != null)
            {
                if (isTextToLong(forceCustom, maxWidth))
                {
                    //Console.WriteLine("Forced custom name is too long: " + forceCustom);
                }
                else
                {
                    //Console.WriteLine("Using forced custom name: " + forceCustom);
                    return(forceCustom);
                }
            }

            // check if name is id (containd F11_ etc...)  if not, continue, else use translated name
            if (startWithId(name))
            {
                //Console.WriteLine("Invalid name: " + tank.Name);
                return(translatedName(tank, maxWidth, name + "_invalid"));
            }

            // if regular name is too long, use transalted name
            if (isTextToLong(name, maxWidth))
            {
                //Console.WriteLine("Name is to long: " + tank.Name);
                return(translatedName(tank, maxWidth, name + "_to_long"));
            }

            return(name);
        }
コード例 #15
0
 private void Start()
 {
     tankStats = GameManager.GM.tankStats;
 }
コード例 #16
0
 protected static string forceCustomName(TankStats tank)
 {
     return(CustomNames.findName(tank));
 }
コード例 #17
0
 // Use this for initialization
 void Awake()
 {
     stats     = GetComponent <TankStats>();
     fireAudio = GetComponent <AudioSource>();
 }
コード例 #18
0
ファイル: Basic.cs プロジェクト: pietrovich/WoT-PogsIconSet
        protected static void DamageHelper(Graphics g, TankStats tankStats, Brush brush, int x, int y, FontAlign align)
        {
            int text = tankStats.IsUsingHe ? tankStats.HeGun.HeDamage : tankStats.ApGun.ApDamage;

            TextHelpers.helperDrawFont4px(g, text.ToString(), brush, x, y, align);
        }
コード例 #19
0
ファイル: GameRules.cs プロジェクト: JamesBabz/TankScape
 // Use this for initialization
 void Start()
 {
     InitiateUI();
     _player      = GameObject.Find("Player");
     _playerStats = _player.GetComponent <TankStats>();
 }
コード例 #20
0
 public void SetStats(TankStats newStats)
 {
     stats  = newStats;
     health = stats.MaximumHealth;
 }