示例#1
0
        /// <summary>
        /// Leaf was hit by tool.
        /// </summary>
        /// <param name="toolTransform">Transform of the tool.</param>
        /// <param name="toolType">Type of tool equipped.</param>
        /// <param name="toolMode">Mode of current tool.</param>
        public override void HitByTool(PlayerServer player, Transform toolTransform, ToolType toolType, ToolMode toolMode)
        {
            // Call the base hit by tool.
            base.HitByTool(player, toolTransform, toolType, toolMode);

            // If this is a leaf blower.
            if (toolType == ToolType.BLOWER)
            {
                // Get the forward of the tool.
                Vector3 toolForward = toolTransform.Forward;

                // Get the vector from the tool to the lefa.
                Vector3 toolToObj = Transform.Position - toolTransform.Position;

                // Get the angle between the two vectors.
                float angleBetween = Utility.AngleBetweenVectors(toolForward, toolToObj);

                // If the angle is negative, rotate the leaf left.
                if (angleBetween < 0.0f)
                {
                    RandomRotateLeft();
                }

                // If the angle is postiive, rotate the leaf right.
                else
                {
                    RandomRotateRight();
                }
            }
        }